<?php

class Application_Model_DbTable_Book extends Zend_Db_Table_Abstract {

    protected $_name = 'book';
	
	public function getBook($id){
        $row = $this->fetchRow("id=".$id);
        return $row;
	}
	
	public function getBookList(){
		$row = $this->fetchAll();
		return $row;
	}	
		
	public function createBook($type, $action, $name,$authorName,$price,$icon,$content,$authorId){
		$row = $this->createRow();
		$row->booktype = $type;
		$row->bookaction = $action;
		$row->name = $name;		
		$row->authorname = $authorName;
		$row->authorId = $authorId;
		$row->price = $price;
		$row->icon = $icon;
		$row->content = $content;
		$row->save();
		return $row;
	}
	
	public function updateBook($id, $type, $action, $name,$authorName,$price,$icon,$content){		
		$row = $this->getBook($id);
		$row->booktype = $type;
		$row->bookaction = $action;
		$row->name = $name;
		$row->authorname = $authorName;
		$row->price = $price;
		$row->icon = $icon;
		$row->content = $content;
		$row->save();
		return $row;
	}	
}
